メインコンテンツへスキップ

All Posts

News bits

Gemini Batch APIが埋め込みとOpenAI互換性をサポート

GoogleがGemini Batch APIで埋め込みモデルとOpenAI互換性をサポートした。新しくリリースされたGemini Embeddingモデルに対応し、非同期処理で50%低い料金での高ボリューム処理が可能になった。

埋め込み処理は$0.075/100万入力トークン(通常価格の50%)で提供され、より高いレート制限での大量処理を実現。

python
from google import genai

client = genai.Client()
uploaded_batch_requests = client.files.upload(file='embedding_requests.jsonl')
batch_job = client.batches.create_embeddings(
    model="gemini-embedding-001",
    src={"file_name": uploaded_batch_requests.name}
)

またOpenAI SDKを使用してGemini Batch APIを利用でき、既存のOpenAIコードを最小限の変更でGeminiに移行可能。

python
from openai import OpenAI

openai_client = OpenAI(
    api_key="GEMINI_API_KEY",
    base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
)

batch = openai_client.batches.create(
    input_file_id=batch_input_file_id,
    endpoint="/v1/chat/completions",
    completion_window="24h"
)

出展:Gemini Batch API now supports Embeddings and OpenAI Compatibility - Google Developers Blog

著者について

Hi there. I'm hrdtbs, a frontend expert and technical consultant. I started my career in the creative industry over 13 years ago, learning on the job as a 3DCG modeler and game engineer in the indie scene.

In 2015 I began working as a freelance web designer and engineer. I handled everything from design and development to operation and advertising, delivering comprehensive solutions for various clients.

In 2016 I joined Wemotion as CTO, where I built the engineering team from the ground up and led the development of core web and mobile applications for three years.

In 2019 I joined matsuri technologies as a Frontend Expert, and in 2020 I also began serving as a technical manager supporting streamers and content creators.

I'm so grateful to be working in this field, doing something that brings me so much joy. Thanks for stopping by.